home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / ROM_Kernel_Manuals / Devices / dev_examples / Speak_Narrator.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-20  |  2.6 KB  |  87 lines

  1. /*
  2.  * Speak_Narrator.c
  3.  *
  4.  * This example program sends a string of phonetic text to the narrator
  5.  * device twice, changing some of the characteristics the second time.
  6.  *
  7.  * Compile with SAS C 5.10  lc -b1 -cfistq -v -y -L
  8.  *
  9.  * Requires Kickstart V37 or greater.
  10.  */
  11.  
  12. #include <exec/types.h>
  13. #include <exec/exec.h>
  14. #include <dos/dos.h>
  15. #include <devices/narrator.h>
  16.  
  17. #include <clib/exec_protos.h>
  18. #include <clib/alib_protos.h>
  19. #include <clib/dos_protos.h>
  20.  
  21. #include <string.h>
  22. #include <stdio.h>
  23.  
  24. #ifdef LATTICE
  25. int CXBRK(void) { return(0); }     /* Disable SAS CTRL/C handling */
  26. int chkabort(void) { return(0); }  /* really */
  27. #endif
  28.  
  29. void main(void)
  30. {
  31. struct  MsgPort     *VoiceMP;
  32. struct  narrator_rb *VoiceIO;
  33. UBYTE   *PhoneticText    = "DHIHS IHZ AHMIY5GAH SPIY5KIHNX.";
  34. BYTE    audio_chan[4]   = {3, 5, 10, 12};
  35.  
  36. if (VoiceMP=CreateMsgPort())  /* Create the message port */
  37.   {                           /* Create the I/O request */
  38.   if (VoiceIO = CreateIORequest(VoiceMP,sizeof(struct narrator_rb)))
  39.     {
  40.     /*Set the NEWIORB bit in the flags field to use the new fields*/
  41.     VoiceIO->flags = NDF_NEWIORB;
  42.  
  43.     /* Open the narrator device */
  44.     if (OpenDevice("narrator.device",0,(struct IORequest *)VoiceIO,0L))
  45.         /* Inform user that it could not be opened */
  46.         printf("Error: narrator.device did not open\n");
  47.     else
  48.         {
  49.          /* Speak the string using the default parameters */
  50.          VoiceIO->ch_masks = &audio_chan[0];
  51.          VoiceIO->nm_masks = sizeof(audio_chan);
  52.          VoiceIO->message.io_Command = CMD_WRITE;
  53.          VoiceIO->message.io_Data = PhoneticText;
  54.          VoiceIO->message.io_Length = strlen(PhoneticText);
  55.          DoIO(VoiceIO);
  56.  
  57.          /* Now change some of the characteristics:
  58.           *    Raise the first formant, lower the third formant,
  59.           *    and move 50% of the way towards AO.
  60.           * and speak it again.
  61.           */
  62.  
  63.         VoiceIO->A1adj = -32;          /* Shut off first formant  */
  64.         VoiceIO->A3adj =  11;          /* Raise the third formant */
  65.         VoiceIO->centralize = 50;      /* Move 50% of the way     */
  66.         VoiceIO->centphon = "AO";      /* towards AO              */
  67.         DoIO(VoiceIO);
  68.  
  69.         /* Close the narrator device */
  70.         CloseDevice((struct IORequest *)VoiceIO);
  71.         }
  72.     /* Delete the IORequest */
  73.     DeleteIORequest(VoiceIO);
  74.     }
  75.   else
  76.     /* Inform user that the I/O request could be created */
  77.     printf("Error: Could not create I/O request\n");
  78.  
  79.   /* Delete the message port */
  80.   DeleteMsgPort(VoiceMP);
  81.   }
  82. else
  83.   /* Inform user that the message port could not be created */
  84.   printf("Error: Could not create message port\n");
  85. }
  86.  
  87.